package com.lianxueda.drawing.mapper;

import com.lianxueda.drawing.domain.pojo.CheckingIn;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
* @author 29264
* @description 针对表【checking_in(state=1是未考勤 考勤表)】的数据库操作Mapper
* @createDate 2024-08-29 09:51:44
* @Entity com.lianxueda.drawing.domain.pojo.CheckingIn
*/
@Mapper
public interface CheckingInMapper extends BaseMapper<CheckingIn> {

    CheckingIn findByCourseIdAndSchedelesIdAndStudentId(@Param("courseId") Integer courseId,@Param("schedelesId")  Integer schedelesId,@Param("studentId")  Integer studentId);

    @Select("<script>" +
            "SELECT student_id AS studentId, course_id AS courseId, status " +
            "FROM checking_in " +
            "WHERE course_id = #{courseId} " +
            "AND student_id IN " +
            "<foreach item='id' collection='studentIds' open='(' separator=',' close=')'>" +
            "#{id}" +
            "</foreach>" +
            "</script>")
    List<CheckingIn> selectByCourseIdAndStudentIds(
            @Param("courseId") Integer courseId,
            @Param("studentIds") List<Integer> studentIds
    );

    boolean removeByCourseIdAndSchedelesId(@Param("courseId") Integer courseId,@Param("schedelesId") Integer schedelesId,@Param("studentId") Integer studentId);
}




